home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
attclk2.arc
/
READCLOC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1986-01-09
|
1KB
|
58 lines
/* :ts=8
*
* readclock()
*
* read internal clock date and time into the buf
* structure. values are adjusted from real time
* clock format to values usable by the library
* time functions.
*
*/
#include "setdate.h"
extern struct tm buf;
readclock()
{
/* the bios rom starts reading the real time clock */
/* by reading the year port twice. if this is not */
/* an incorrect value may be read from the port. */
inportb(0x7f);
inportb(0x7f);
/* year */
/* the real time clock stores the year as a range 0-7 */
/* from a leap year. */
buf.tm_year = readport(0x7f) + LEAP_YEAR;
/* month */
/* the real time clock stores the month as 1-12. it's */
/* adjusted here to be 0-11 */
buf.tm_mon = readport(0x7c) * 10;
buf.tm_mon += (readport(0x7b) - 1);
/* day of week */
/* the real time clock stores the day of week as 1-7. */
/* it's adjusted here to be 0-6 */
buf.tm_wday = readport(0x7a) - 1;
/* day */
buf.tm_mday = readport(0x79) * 10;
buf.tm_mday += readport(0x78);
/* hour */
buf.tm_hour = readport(0x77) * 10;
buf.tm_hour += readport(0x76);
/* minute */
buf.tm_min = readport(0x75) * 10;
buf.tm_min += readport(0x74);
/* second */
buf.tm_sec = readport(0x73) * 10;
buf.tm_sec += readport(0x72);
/* hundreths */
buf.tm_hsec = readport(0x71) * 10;
}